package jjn.effective_java.chapter6.item40;

import java.util.HashSet;
import java.util.Set;

/**
 * @author Jjn
 * @since 2023/4/30 08:46
 */
public class Bigram {
    private final char first;
    private final char second;
    
    public Bigram(final char first, final char second) {
        this.first = first;
        this.second = second;
    }
    
    public boolean equals(Bigram o) {
        return o.first == this.first && o.second == this.second;
    }
    
    @Override
    public int hashCode() {
        int result = first;
        result = 31 * result + (int) second;
        return result;
    }
    
    public static void main(String[] args) {
        Set<Bigram> set = new HashSet<>();
        for (int i = 0; i < 10; i++) {
            for (char j = 'a'; j <= 'z'; j++) {
                set.add(new Bigram(j, j));
            }
        }
        System.out.println(set.size());
    }
}
